﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace PRE.Help
{
    public partial class FrmXemthongtinnhanvien : DevExpress.XtraEditors.XtraForm
    {
        #region Variable
        DAL.EntitiesDAL.NhanvienDAL _dal = new DAL.EntitiesDAL.NhanvienDAL();
        BLL.EntitiesBLL.NhanvienBLL _bll = new BLL.EntitiesBLL.NhanvienBLL();

        DataTable _dtb = new DataTable();
        #endregion

        #region Inits
        public FrmXemthongtinnhanvien()
        {
            InitializeComponent();
        }
        #endregion

        #region Thoát
        private void bto_Thoát_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion

        #region Xem
        private void bto_Tim_Click(object sender, EventArgs e)
        {
            string ma = Convert.ToString(txt_manhanvien.Text);
            DataTable _dtbtim = _dal.Select_Nhanvien_All(ma);
            try
            {
                ResetText();
                ClearData();
                if (_dtbtim != null)
                {
                    txt_hoten.DataBindings.Add("Text", _dtbtim, ".HOTEN");
                    txt_gioitinh.DataBindings.Add("Text", _dtbtim, ".GIOITINH");
                    txt_ngaysinh.DataBindings.Add("Text", _dtbtim, ".NGAYSINH");
                    txt_cmnd.DataBindings.Add("Text", _dtbtim, ".CMND");
                    txt_dantoc.DataBindings.Add("Text", _dtbtim, ".DANTOC");
                    txt_tongiao.DataBindings.Add("Text", _dtbtim, ".TONGIAO");
                    txt_quequan.DataBindings.Add("Text", _dtbtim, ".QUEQUAN");
                    txt_choohiennay.DataBindings.Add("Text", _dtbtim, ".CHOOHIENNAY");
                    txt_hocvan.DataBindings.Add("Text", _dtbtim, ".TRINHDOHOCVAN");
                    txt_dienthoai.DataBindings.Add("Text", _dtbtim, ".DIENTHOAI");
                    txt_email.DataBindings.Add("Text", _dtbtim, ".EMAIL");
                    txt_ngaythamgia.DataBindings.Add("Text", _dtbtim, ".NGAYTHAMGIACONGTAC");
                    txt_ngaynghi.DataBindings.Add("Text", _dtbtim, ".NGAYNGHICONGTAC");
                    txt_mucluong.DataBindings.Add("Text", _dtbtim, ".MUCLUONG");
                    txt_hesoluong.DataBindings.Add("Text", _dtbtim, ".HESOLUONG");
                    txt_hesophucap.DataBindings.Add("Text", _dtbtim, ".HESOPHUCAP");
                    txt_trinhdo.DataBindings.Add("Text", _dtbtim, ".TENBAC");
                    txt_tenphongban.DataBindings.Add("Text", _dtbtim, ".TENPHONGBAN");
                    txt_tenchucvu.DataBindings.Add("Text", _dtbtim, ".TENCHUCVU");
                    txt_chuyenmon.DataBindings.Add("Text", _dtbtim, ".CHUYENMON");
                    txt_supham.DataBindings.Add("Text", _dtbtim, ".CHUNGCHI_SP");
                    txt_ngoaingu.DataBindings.Add("Text", _dtbtim, ".CHUNGCHI_NN");
                    txt_tinhoc.DataBindings.Add("Text", _dtbtim, ".CHUNGCHI_TH");
                    txt_chinhtri.DataBindings.Add("Text", _dtbtim, ".CHUNGNHAN");
                    txt_thamnien.DataBindings.Add("Text", _dtbtim, ".THAMNIEN");                  
                }
               
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Không tìm thấy nhân viên này!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        #endregion

        #region From load
        private void FrmXemthongtinnhanvien_Load(object sender, EventArgs e)
        {
            txt_chinhtri.Properties.ReadOnly = true;
            txt_choohiennay.Properties.ReadOnly = true;
            txt_chuyenmon.Properties.ReadOnly = true;
            txt_cmnd.Properties.ReadOnly = true;
            txt_dantoc.Properties.ReadOnly = true;
            txt_dienthoai.Properties.ReadOnly = true;
            txt_email.Properties.ReadOnly = true;
            txt_gioitinh.Properties.ReadOnly = true;
            txt_hesoluong.Properties.ReadOnly = true;
            txt_hesophucap.Properties.ReadOnly = true;
            txt_hocvan.Properties.ReadOnly = true;
            txt_hoten.Properties.ReadOnly = true;
            txt_mucluong.Properties.ReadOnly = true;
            txt_ngaynghi.Properties.ReadOnly = true;
            txt_ngaysinh.Properties.ReadOnly = true;
            txt_ngaythamgia.Properties.ReadOnly = true;
            txt_ngoaingu.Properties.ReadOnly = true;
            txt_quequan.Properties.ReadOnly = true;
            txt_supham.Properties.ReadOnly = true;
            txt_tenchucvu.Properties.ReadOnly = true;
            txt_tenphongban.Properties.ReadOnly = true;
            txt_thamnien.Properties.ReadOnly = true;
            txt_tinhoc.Properties.ReadOnly = true;
            txt_tongiao.Properties.ReadOnly = true;
            txt_trinhdo.Properties.ReadOnly = true;
        }
        #endregion

        protected void ResetText()
        {
            txt_chinhtri.ResetText();
            txt_choohiennay.ResetText();
            txt_chuyenmon.ResetText();
            txt_cmnd.ResetText();
            txt_dantoc.ResetText();
            txt_dienthoai.ResetText();
            txt_email.ResetText();
            txt_gioitinh.ResetText();
            txt_hesoluong.ResetText();
            txt_hesophucap.ResetText();
            txt_hocvan.ResetText();
            txt_hoten.ResetText();
            txt_mucluong.ResetText();
            txt_ngaynghi.ResetText();
            txt_ngaysinh.ResetText();
            txt_ngaythamgia.ResetText();
            txt_ngoaingu.ResetText();
            txt_quequan.ResetText();
            txt_supham.ResetText();
            txt_tenchucvu.ResetText();
            txt_tenphongban.ResetText();
            txt_thamnien.ResetText();
            txt_tinhoc.ResetText();
            txt_tongiao.ResetText();
            txt_trinhdo.ResetText();
        }

        protected void ClearData()
        {
            txt_hoten.DataBindings.Clear();
            txt_gioitinh.DataBindings.Clear();
            txt_ngaysinh.DataBindings.Clear();
            txt_cmnd.DataBindings.Clear();
            txt_dantoc.DataBindings.Clear();
            txt_tongiao.DataBindings.Clear();
            txt_quequan.DataBindings.Clear();
            txt_choohiennay.DataBindings.Clear();
            txt_hocvan.DataBindings.Clear();
            txt_dienthoai.DataBindings.Clear();
            txt_email.DataBindings.Clear();
            txt_ngaythamgia.DataBindings.Clear();
            txt_ngaynghi.DataBindings.Clear();
            txt_mucluong.DataBindings.Clear();
            txt_hesoluong.DataBindings.Clear();
            txt_hesophucap.DataBindings.Clear();
            txt_trinhdo.DataBindings.Clear();
            txt_tenphongban.DataBindings.Clear();
            txt_tenchucvu.DataBindings.Clear();
            txt_chuyenmon.DataBindings.Clear();
            txt_supham.DataBindings.Clear();
            txt_ngoaingu.DataBindings.Clear();
            txt_tinhoc.DataBindings.Clear();
            txt_chinhtri.DataBindings.Clear();
            txt_thamnien.DataBindings.Clear();
        }
    }
}
